home *** CD-ROM | disk | FTP | other *** search
- Path: prairienet.org!sjmccaug
- From: sjmccaug@prairienet.org (Scott J. McCaughrin)
- Newsgroups: comp.lang.c++
- Subject: Re: Passing numbers
- Date: 28 Mar 1996 00:04:09 GMT
- Organization: University of Illinois at Urbana
- Message-ID: <4jcl1p$5mn@vixen.cso.uiuc.edu>
- References: <4jchjq$i1k@news1.h1.usa.pipeline.com> <40.88694.1613@channel1.com>
- Reply-To: sjmccaug@prairienet.org (Scott J. McCaughrin)
- NNTP-Posting-Host: firefly.prairienet.org
-
-
- In a previous article, grantp@usa.pipeline.com (Pete Grant) says:
-
- >On Mar 27, 1996 06:28:00 in article <Passing numbers>,
- >'dspse.bedford@channel1.com (Dspse Bedford)' wrote:
- >
- >
- >>Lets say I have the following class and functions defined:
- >>
- >>class A{
- >>...
- >>void func(long lvar);
- >>void func(int ivar);
- >>....
- >>};
- >>I know that the compiler can not decide if
- >>A a;
- >>a.func(30);
- >>
- >>should match up with the int version of func or the long version of
- >>func. However, is there anyway I can tell the compiler which one to
- >>use as a default definition such that the above would always be mapped
- >>to my default definition. In other words, if an arguement, such as
- >>a number, causes an ambiguity use the default definition. Does anyone
- >>know how or why not?
- >>
- >
- >Which compiler doesn't distinguish between int and long?
- >MSVC++4.1 does.
- >
- >a.func(30) => func(int);
- >a.func(5L) => func(long);
- >
- >--
-
- That wasn't the author's point: 30 is an int that also falls
- in the range of a long. The answer is that, owing to its
- size, 30 "defaults" to an int, just as 66000 defaults to a
- long. So yes, there is a way to to choose between the two.
-
- Scott
-
- >Kalevi, Inc.
- >Software Engineering & development
- >
-
-